<?php

/**
 * Log actions.
 *
 * @package    scar
 * @subpackage Log
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
 */

class LogActions extends sfActionsCrud
{
  public function executeLogin(sfWebRequest $request)
  {
  	
  	$this->form = new LoginForm();
  	
    if ($request->isMethod('post'))
  	{
  	  $this->form->bind($request->getParameter('login'));
  	  if ($this->form->isValid())
  	  {
  	  	$user = Doctrine::getTable('Usuario')->findOneByLogin($this->form->getValue('login'));
  	    $this->getUser()->logIn($user);
        
        return $this->redirect('@inicio');
  	  }
  	}
  }
  public function executeLogout()
  {
  	if ($this->getUser()->isAuthenticated())
  	{
  	  $this->getUser()->setAuthenticated(false);
  	}
  	
  	return $this->redirect('@log_login');
  }
}
